﻿using System;
using System.Collections.Generic;
using System.Text;
using WarehouseWebAPP.code.DAL;
using WarehouseWebAPP.code.DAL.UserTypeDSTableAdapters;
using System.Data;



//////////////////////////////////////////////////////////////////
/////Params names , must match the ones in the Grid or Dataset////
/////in this case Database since we have no Mappings//////////////
//////////////////////////////////////////////////////////////////
namespace WarehouseWebAPP.code.BLL
{
    public class UserTypeBLL
    {
        private user_type_tableTableAdapter UserTypeAdapter = null;
        public user_type_tableTableAdapter Adapter
        {
            get
            {
                if (UserTypeAdapter == null) UserTypeAdapter = new user_type_tableTableAdapter();
                return UserTypeAdapter;
            }
        }
        public UserTypeDS.user_type_tableDataTable UserTypeGet()
        {
            return Adapter.GetData();

        }

        public UserTypeDS.user_type_tableDataTable UserTypeGetByNum(Guid user_type_num)
        {
            if (user_type_num == null) 
                throw new Exception("User Type Num is missing");
            
            return Adapter.UserTypeGetByNum(user_type_num);

        }

        public UserTypeDS.user_type_tableDataTable UserTypeGetByName(string user_type)
        {
            if (user_type == null)
                throw new Exception("User Type Name is missing");

            return Adapter.UserTypeGetByName(user_type);

        }
        public void UserTypeInsert(string user_type)
        {
            if (user_type == null)
                throw new Exception("User Type is missing");
            Adapter.UserTypeInsert(user_type);
        }



        public void UserTypeDelete(Guid user_type_num)
        {
            if (user_type_num == null)
                throw new Exception("Users Type Number is missing");
            if (Adapter.UserTypeDelete(user_type_num) < 1)
                throw new Exception("Users Type was not Deleted");
        }


        public void UserTypeUpdate(Guid user_type_num, string user_type)
        {
            if (user_type_num == null)
                throw new Exception("User Type Number is missimg");
            if (user_type == null)
                throw new Exception("User Type is missing");
            if (Adapter.UserTypeUpdate(user_type, user_type_num) < 1)
                throw new Exception("User Type was no updated");
        }

        public bool UserTypeExist(string userType)
        {
            if (userType == null)
                throw new Exception("User Type is missing");
            if ((int)(Adapter.UserTypeExists(userType)) < 1) return false;
            return true;

        }
        
    }
}
